A prefix (when developing bots), is a string of characters a user will have to type before a command, to denote input intended for your bot. The following example adds a (bad) prefix.
const HaSeul = require('haseul').default;
const router = new HaSeul();
router
.set('prefix', ['!']) // Set the prefix to !
.command('hello', () => {
console.log('Hello world!')
})
// This input matches both the prefix, and the command "hello".
router.route('!hello')
// This input does not match the prefix, so does not print "Hello world!".
router.route('hello')
When developing bots for public use, be mindful of using a prefix that is:
!
or any other single character, as conflicts are bound to occur.€£$
may not be possible to type on some user's keyboards.é
.Some people may wish to add more than one prefix to their bot. To do this, add more than one prefix to the array.
router.set('prefix', ['!', 'oppa'])
// WRONG
// WRONG
// WRONG
router
.set('prefix', ['!'])
.set('prefix', ['oppa'])
This incorrect example will have the oppa
prefix overwriting the !
prefix.
Generated using TypeDoc